<?php


namespace App\Admin\Controller\Wechat;


use App\Admin\Controller\AdminBaseController;
use App\Admin\Services\Wechat\CompanyMiniProgramService;

class CompanyMiniProgramController extends AdminBaseController {
    /**
     * 获取授权连接
     *
     * @param CompanyMiniProgramService $service
     */
    public function getComponentLoginPageUrl(CompanyMiniProgramService $service) {
        
        return $this->success($service->getComponentLoginPageUrl());
    }
    
    /**
     * 获取草稿列表
     *
     * @param CompanyMiniProgramService $service
     *
     * @return mixed
     */
    public function draftsList(CompanyMiniProgramService $service) {
        return $this->success($service->getDraftsList());
    }
    
    /**
     * 获取模板列表
     *
     * @param CompanyMiniProgramService $service
     *
     * @return mixed
     */
    public function templateList(CompanyMiniProgramService $service) {
        return $this->success($service->getTemplateList());
    }
    
    /**
     * 将草稿添加到模板中
     *
     * @param CompanyMiniProgramService $service
     * @param int                       $draftId
     *
     * @return mixed
     */
    public function createTemplateCreateFromDraft(CompanyMiniProgramService $service, int $draftId) {
        return $this->success($service->createTemplateCreateFromDraft($draftId));
    }

    /**
     * 删除指定魔板
     *
     * @param CompanyMiniProgramService $service
     * @param $templateId
     * @return mixed
     * @throws \App\Admin\Exceptions\Wechat\CompanyMiniProgramException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     */
    public function deleteTemplate(CompanyMiniProgramService $service, $templateId) {
        return $this->success($service->deleteTemplate($templateId));
    }
}